﻿using System;
using System.Application;
using System.Collections.Generic;
using System.Domain.IRepository;
using System.Linq;
using System.Repository;
using System.Threading.Tasks;
using Domain.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Ubiquity.Core.Extend;
using Ubiquity.Core.Web;
using Ubiquity.Web.Filters;

namespace Ubiquity.Web.Areas.SystemManage.Controllers
{

    /// <summary>
    ///程序日志 控制器 
    /// </summary>	
    [Area("SystemManage")]
    public class SysProgramLogController : BaseController
    {
        private readonly SysProgramLogService _service;

        public SysProgramLogController(SysProgramLogService service)
        { 
            _service = service;
        }


        [HttpGet]
        [Authorize]
        public ActionResult GetGridPaginationJson(WebPagination pagination, string start, string end)
        {
            DateTime startDate = Convert.ToDateTime(Validate.IsDate(start) ? start : "1979-01-01");
            DateTime endDate = Validate.IsDate(end) ? Convert.ToDateTime(end) : DateTime.Now;
            var paging = pagination.Change();
            var data = new
            {
                rows = _service.GetList(paging, startDate, endDate.AddDays(1)),
                total = paging.Total,
                page = paging.Page + 1,
                records = paging.Records
            };
            return Content(data.ToJson());
        }
        [HttpGet]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = _service.GetEntity(keyValue);
            return Content(data.ToJson());
        }


    }

}
